﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using TaskManagement.ModelLayer;

namespace TaskManagement.WcfServiceLibrary
{
   
    [ServiceContract]
    public interface ITaskService
    {
        [OperationContract]
        [WebGet]
        string GetData(int value);

        #region Tasks
        [OperationContract]
        IList<Task> SearchTasks(Task t);

        [OperationContract]
        [WebGet]
        /// <summary>
        /// Searches using the supplied data, not all values must be supplied
        /// Use for rest only
        /// </summary>
        /// <param name="id">The id of the task</param>
        /// <param name="description">Description of the task</param>
        /// <param name="account">Account of the task</param>
        /// <param name="delivery">Delivery of the task</param>
        /// <param name="tag">Tag of the task</param>
        /// <param name="date">Date of the task as a datetime</param>
        /// <param name="status">Status of the task</param>
        /// <param name="estimate">Estimate of the task, must be one greather than the actural value</param>
        /// <param name="timespent">Timespent of the task, must be one greather than the actural value</param>
        /// <param name="employeeid">Id of the employee the task belongs to, must be one greather than the actural value</param>
        /// <returns>A list of tasks matching the search or and empty list</returns>
        IList<Task> SearchTasksRest(int id, string description, string account, string delivery, string tag,
            DateTime date, string status, int estimate, int timespent, int employeeid);
        
        [OperationContract]
        int CreateTask(Task task);
        
        [OperationContract]
        [WebGet]
        int CreateTaskRest(string description, string account, string delivery, string tag,
            DateTime date, string status, int estimate, int timespent);

        [OperationContract]
        int DeleteTasks(IList<Task> tasks);

        [OperationContract]
        [WebGet]
        int DeleteTaskRest(int id);

        [OperationContract]
        int UpdateTask(Task task);

        [OperationContract]
        [WebGet]
        int UpdateTaskRest(int id, string description, string account, string delivery, string tag,
            DateTime date, string status, int estimate, int timespent);
        
        [OperationContract]
        /// <summary>
        /// Gets all accounts
        /// </summary>
        /// <returns>A IList with all accounts</string></returns>
        IList<string> GetAccounts();

        [OperationContract]
        /// <summary>
        /// Gets all tags
        /// </summary>
        /// <returns>A IList with all tags</returns>
        IList<string> GetTags();

        [OperationContract]
        /// <summary>
        /// Gets all deliverys
        /// </summary>
        /// <returns>A IList with all deliverys</returns>
        IList<string> GetDeliverys();

        #endregion

        # region Workflows

        [OperationContract]
        /// <summary>
        /// Searches trough the workflows in the database
        /// </summary>
        /// <param name="searchWorkflow">The workflow containing the data to search for</param>
        /// <returns>A list of workflows that match the search or a empty list if nothing is found</returns>
        List<Workflow> SearchWorkflow(Workflow searchWorkflow);
        
        [OperationContract]
        [WebGet]
        /// <summary>
        /// Searches trough the workflows in the database
        /// Should only be used via rest
        /// All parametars are optional
        /// </summary>
        /// <param name="id">int id must be one higher than the value to search for if supplied</param>
        /// <param name="name">The name of the workflow</param>
        /// <param name="description">The description of the workflow</param>
        /// <param name="startdate">The start date of the workflow</param>
        /// <returns></returns>
        List<Workflow> SearchWorkflowRest(int id, string name,string description,DateTime startdate);

        [OperationContract]
        /// <summary>
        /// Creates a workflow in the database
        /// </summary>
        /// <param name="w">The workflow containing the data to be inserted,
        /// Cannot have a id other than 0</param>
        /// <returns>The id of the task or nothing 0 if an error occured</returns>
        int CreateWorkflow(Workflow w);

        [OperationContract]
        [WebGet]
        /// <summary>
        /// Creates a workflow in the database
        /// This method should only be used via REST
        /// </summary>
        /// <param name="name">The name of the workflow</param>
        /// <param name="description">The description of the workflow</param>
        /// <param name="startdate">The startdate of the workflow</param>
        /// <returns>The id of the task or nothing 0 if an error occured</returns>
        int CreateWorkflowRest(string name, string description, DateTime startdate);

        [OperationContract]
        /// <summary>
        /// Updates a workflow in the database
        /// Cannot update if starte is after a date of one of the tasks in this workflow
        /// </summary>
        /// <param name="workflow">The workflow containing the data </param>
        /// <returns>"1" on "0" on db error or a decescription of the error</returns>
        string UpdateWorkflow(Workflow workflow);

        [OperationContract]
        [WebGet]
        /// <summary>
        /// Updates a workflow in the datebase
        /// Cannot update if starte is after a date of one of the tasks in this workflow
        /// Only use this method via REST
        /// </summary>
        /// <param name="id">The original id of the workflow</param>
        /// <param name="name">The new name</param>
        /// <param name="description">The new description</param>
        /// <param name="startdate">The new startdate</param>
        /// <returns>"1" on "0" on db error or a decescription of the error</returns>
        string UpdateWorkflowRest(int id, string name, string description, DateTime startdate);

        [OperationContract]
        /// <summary>
        /// Delete the a list of workflows from
        /// </summary>
        /// <param name="workflows">The Ilist of workflows</param>
        /// <returns>1 on succes and 0 if an error occured</returns>
        int DeleteWorkflows(IList<Workflow> workflows);


        [OperationContract]
        [WebGet]
        /// <summary>
        /// Deletes a workflow from the database
        /// </summary>
        /// <param name="id">The id of the workflow</param>
        /// <returns>1 on succes and 0 if an error occured</returns>
        int DeleteWorkflow(int id);




        # endregion

    }


}
